/**
 * 
 */
package com.example.secondassignment;


import com.example.secondassignment.R;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.widget.Toast;



/**
 * @author jlnmsi
 *
 */
public class AlarmReceiver extends BroadcastReceiver {

	public static final int NOTIFICATION_ID = 1543;
	private NotificationManager notifManager;

	
	
	@Override
	public void onReceive(Context ctx, Intent intent) {

		AlarmClock.playAlarmSound();
		
		/* 1. Setup Notification Builder */			
		NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx); 
		
		/* 2. Configure Notification Alarm */
		builder.setSmallIcon(R.drawable.ic_launcher)
			.setWhen(System.currentTimeMillis())
			.setTicker("Alarm has gone off");
			//.setAutoCancel(true);
			
			
		/* 3. Configure Drop-down Action */
		builder.setContentTitle("Click to continue!");
//				.setContentText("Click to continue.")
//				.setContentInfo("Click!");
		Intent newintent = new Intent(ctx, NotificationDisplay.class);   // Notification intent
		PendingIntent notifIntent = PendingIntent.getActivity(ctx, 0, newintent, 0);
		builder.setContentIntent(notifIntent);
		
		/* 4. Create Notification and use Manager to launch it */
		Notification notification = builder.build();	
		String ns = Context.NOTIFICATION_SERVICE;
		notifManager = (NotificationManager) ctx.getSystemService(ns);
		notifManager.notify(NOTIFICATION_ID, notification);
		
	}
}

